import axios from '@/libs/api.request'

export const addManageUser = ({ manage_name, manage_phone, manage_pass, avator, access, manage_state, team_name }) => {
  const data = {
    manage_name,
    manage_phone,
    manage_pass,
    avator,
    access,
    manage_state,
    team_name
  }

  return axios.request({
    url: 'add_manage_user',
    data,
    method: 'post'
  })
}

export const getAccessList = () => {
  return axios.request({
    url: 'get_access_list',
    method: 'get'
  })
}

export const getManageUser = ({ pageNum, pageSize }) => {
  return axios.request({
    url: 'get_manage_user',
    params: {
      pageNum,
      pageSize
    },
    method: 'get'
  })
}

export const getTeamUser = ({ pageNum, pageSize }) => {
  return axios.request({
    url: 'get_team_user',
    params: {
      pageNum,
      pageSize
    },
    method: 'get'
  })
}

export const setManageState = ({ manage_id, setAction }) => {
  return axios.request({
    url: 'set_manage_state',
    params: {
      manage_id,
      setAction
    },
    method: 'get'
  })
}

export const delManageUser = (manage_id) => {
  return axios.request({
    url: 'del_manage_user',
    params: {
      manage_id
    },
    method: 'get'
  })
}

export const editManageUser = ({ manage_id, manage_name, manage_pass, manage_phone, avator, access, manage_state, team_name }) => {
  const data = {
    manage_id,
    manage_name,
    manage_pass,
    manage_phone,
    avator,
    access,
    manage_state,
    team_name
  }
  return axios.request({
    url: 'edit_manage_user',
    data,
    method: 'post'
  })
}

export const getPerson = () => {
  return axios.request({
    url: 'get_manage_person',
    method: 'get'
  })
}

export const editPerson = ({ manage_name, manage_phone, manage_pass, team_name, avator }) => {
  return axios.request({
    url: 'edit_manage_person',
    data: { manage_name, manage_phone, manage_pass, team_name, avator },
    method: 'post'
  })
}
